
data sf20;
set iscience.sf20;
run;


*************************************************************************************
Table 1: Descriptive statistics for the SF-20 subscales
*************************************************************************************;

proc means data=sf20; where visit=1; var P_all M_all G_all R_all S_all pn_all; run;
proc means data=sf20; where visit=7; var P_all M_all G_all R_all S_all pn_all; run;
proc means data=sf20; where visit=8; var P_all M_all G_all R_all S_all pn_all; run;
proc means data=sf20; var P_all M_all G_all R_all S_all pn_all; run;


*************************************************************************************
Table 2: Internal consistency (Cronbach�s alpha) of the SF-20 subscales
*************************************************************************************;

PROC CORR data=sf20 alpha nomiss;
where visit=1 ;
VAR p1-p6;
RUN;
PROC CORR data=sf20 alpha nomiss;
where visit=7 ;
VAR p1-p6;
RUN;
PROC CORR data=sf20 alpha nomiss;
where visit=8 ;
VAR p1-p6;
RUN;
PROC CORR data=sf20 alpha nomiss;
VAR p1-p6;
RUN;

PROC CORR data=sf20 alpha nomiss;
where visit=1;
VAR M1-M5;
RUN;
PROC CORR data=sf20 alpha nomiss; 
where visit=7;
VAR M1-M5;
RUN;
PROC CORR data=sf20 alpha nomiss; 
where visit=8;
VAR M1-M5;
RUN;
PROC CORR data=sf20 alpha nomiss; 
VAR M1-M5;
RUN;

PROC CORR data=sf20 alpha nomiss;
where visit=1;
VAR g1-g5;
RUN;
PROC CORR data=sf20 alpha nomiss;
where visit=7;
VAR g1-g5;
RUN;
PROC CORR data=sf20 alpha nomiss;
where visit=8;
VAR g1-g5;
RUN;
PROC CORR data=sf20 alpha nomiss;
VAR g1-g5;
RUN;

PROC CORR data=sf20 alpha nomiss;
VAR s1;
RUN;
PROC CORR data=sf20 alpha nomiss;
VAR pn1;
RUN;

PROC CORR data=sf20 alpha nomiss;
where visit=1;
VAR R1-R2;
RUN;
PROC CORR data=sf20 alpha nomiss;
where visit=7;
VAR R1-R2;
RUN;
PROC CORR data=sf20 alpha nomiss;
where visit=8;
VAR R1-R2;
RUN;
PROC CORR data=sf20 alpha nomiss;
VAR R1-R2;
RUN;



************************************************************************************* 
Table 3. Factor analysis 
*************************************************************************************;

* Standardize ;
PROC STANDARD DATA=sf20 MEAN=0 STD=1 OUT=sf_z;
  VAR p1-p6 m1-m5 g1-g5 ;
RUN;

%macro fac(var1);
PROC FACTOR DATA = sf_z
METHOD = PRINCIPAL PRIORS = SMC SCREE
NFACTOR = 3 PREPLOT
ROTATE = VARIMAX REORDER PLOT
OUT = results;
where visit=&var1;
VAR  p1-p6 m1-m5 g1-g5;
RUN;
%mend;
%fac(1); 
%fac(7); 
%fac(8); 


************************************************************************************* 
Table 4. Model fit indices for theoretical and empirical CFA models 
*************************************************************************************;

* Theoretical model: Physical Function;
%macro visit(var1);
ods graphics on;
proc calis data=sf_z plots=pathdiagram  covariance maxiter=50000 method=ml;
   where visit=&var1;
   lineqs
      P1 = LV01 * F1 + E1,
      P2 = LV02 * F1 + E2,
      P3 = LV03 * F1 + E3,
      P4 = LV04 * F1 + E4,
      P5 = LV05 * F1 + E5,
      P6 = LV06 * F1 + E6
	;
   std
      F1 = 1,
      E1-E6 = vare1-vare6;
   var
      P1 P2 P3 P4 P5 P6;
   pathdiagram diagram = standard;
run;
ods graphics off;
%mend;
%visit(1);
%visit(7);
%visit(8);

* Theoretical model: Mental Health;
%macro visit(var1);
ods graphics on;
proc calis data=sf_z plots=pathdiagram covariance maxiter=50000 method=ml;
   where visit=&var1;
   lineqs
      M1 = LV07 * F2 + E7,
      M2 = LV08 * F2 + E8,
      M3 = LV09 * F2 + E9,
      M4 = LV10 * F2 + E10,
      M5 = LV11 * F2 + E11;
   std
      F2 = 1,
      E7-E11 = vare7-vare11;
   var
      M1 M2 M3 M4 M5;
   pathdiagram diagram = standard;
run;
ods graphics off;
%mend;
%visit(1);
%visit(7);
%visit(8);

* Theoretical model: General Health;
%macro visit(var1);
ods graphics on;
proc calis data=sf_z plots=pathdiagram covariance maxiter=50000 method=ml;
   where visit=&var1;
   lineqs
      G1 = LV07 * F2 + E7,
      G2 = LV08 * F2 + E8,
      G3 = LV09 * F2 + E9,
      G4 = LV10 * F2 + E10,
      G5 = LV11 * F2 + E11;
   std
      F2 = 1,
      E7-E11 = vare7-vare11;
   var
      G1 G2 G3 G4 G5;
run;
ods graphics off;
%mend;
%visit(1);
%visit(7);
%visit(8);


* Emperical model: Physical Function;
%macro visit(var1);
ods graphics on;
proc calis data=sf_z plots=pathdiagram  covariance maxiter=50000 method=ml;
   where visit=&var1;
   lineqs
      P1 = LV01 * F1 + E1,
      P2 = LV02 * F1 + E2,
      P3 = LV03 * F1 + E3,
      P4 = LV04 * F1 + E4,
      P5 = LV05 * F1 + E5,
      P6 = LV06 * F1 + E6
	;
   std
      F1 = 1,
      E1-E6 = vare1-vare6;
   var
      P1 P2 P3 P4 P5 P6;
   pathdiagram diagram = standard;
run;
ods graphics off;
%mend;
%visit(1);
%visit(7);
%visit(8);

* Emperical model: Mental Health;
%macro visit(var1);
ods graphics on;
proc calis data=sf_z plots=pathdiagram covariance maxiter=50000 method=ml;
   where visit=&var1;
   lineqs
      M1 = LV07 * F2 + E7,
      M3 = LV08 * F2 + E8,
      M5 = LV09 * F2 + E9,
      G2 = LV10 * F2 + E10,
      G5 = LV11 * F2 + E11;
   std
      F2 = 1,
      E7-E11 = vare7-vare11;
   var
      M1 M3 M5 G2 G5;
   pathdiagram diagram = standard;
run;
ods graphics off;
%mend;
%visit(1);
%visit(7);
%visit(8);

* Emperical model: General Health;
%macro visit(var1);
ods graphics on;
proc calis data=sf_z plots=pathdiagram covariance maxiter=50000 method=ml;
   where visit=&var1;
   lineqs
      G1 = LV07 * F2 + E7,
      G3 = LV08 * F2 + E8,
      G4 = LV09 * F2 + E9,
      M2 = LV10 * F2 + E10,
      M4 = LV11 * F2 + E11;
   std
      F2 = 1,
      E7-E11 = vare7-vare11;
   var
      G1 G3 G4 M2 M4;
run;
ods graphics off;
%mend;
%visit(1);
%visit(7);
%visit(8);



*************************************************************************************
Figure 1. Pearson correlation coefficients (r) between the subscales of the SF-20  
*************************************************************************************;

data v1; set sf20; 
if visit=1;
keep enc_id p_all m_all r_all g_all s_all pn_all;
run;

data v1_1; set v1;
v1_p_all=p_all;
v1_m_all=m_all;
v1_r_all=r_all;
v1_g_all=g_all;
v1_s_all=s_all;
v1_pn_all=pn_all;
keep enc_id 
v1_p_all
v1_m_all
v1_r_all
v1_g_all
v1_s_all
v1_pn_all;
run;

data v7; set sf20; 
if visit=7;
keep enc_id p_all m_all r_all g_all s_all pn_all;
run;

data v7_1; set v7;
v7_p_all=p_all;
v7_m_all=m_all;
v7_r_all=r_all;
v7_g_all=g_all;
v7_s_all=s_all;
v7_pn_all=pn_all;
keep enc_id 
v7_p_all
v7_m_all
v7_r_all
v7_g_all
v7_s_all
v7_pn_all;
run;

data v8; set sf20; 
if visit=8;
keep enc_id p_all m_all r_all g_all s_all pn_all;
run;

data v8_1; set v8;
v8_p_all=p_all;
v8_m_all=m_all;
v8_r_all=r_all;
v8_g_all=g_all;
v8_s_all=s_all;
v8_pn_all=pn_all;
keep enc_id 
v8_p_all
v8_m_all
v8_r_all
v8_g_all
v8_s_all
v8_pn_all;
run;

proc sort data=v1_1; by enc_id; run;
proc sort data=v7_1; by enc_id; run;
proc sort data=v8_1; by enc_id; run;
data v178; merge v1_1 v7_1 v8_1; by enc_id; run;

proc sort data=sf20; 		by enc_id visit;run;
proc sort data=v178; 		by enc_id ; 	run;
data sf_1; merge sf20 v178;	by enc_id; 		run;

proc corr data=sf_1 alpha;  var v1_p_all v7_p_all v8_p_all; 	run;
proc corr data=sf_1 alpha;  var v1_m_all v7_m_all v8_m_all; 	run;
proc corr data=sf_1 alpha;  var v1_g_all v7_g_all v8_g_all; 	run;
proc corr data=sf_1 alpha;  var v1_r_all v7_r_all v8_r_all; 	run;
proc corr data=sf_1 alpha;  var v1_s_all v7_s_all v8_s_all; 	run;
proc corr data=sf_1 alpha;  var v1_pn_all v7_pn_all v8_pn_all; 	run;



*************************************************************************************
Supplementary Table S1 
*************************************************************************************;

* Theoretical model: Mental Health;
%macro visit(var1);
ods graphics on;
proc calis data=sf_z plots=pathdiagram covariance maxiter=50000 method=ml;
   where visit=&var1;
   lineqs
      M1 = LV07 * F2 + E7,
      M2 = LV08 * F2 + E8,
      M3 = LV09 * F2 + E9,
      M4 = LV10 * F2 + E10,
      M5 = LV11 * F2 + E11;
   std
      F2 = 1,
      E7-E11 = vare7-vare11;
   cov
      E10 E11 = CE10E11;  
   var
      M1 M2 M3 M4 M5;
   pathdiagram diagram = standard;
run;
ods graphics off;
%mend;
%visit(1);
%visit(7);
%visit(8);

* Theoretical model: General Health;
%macro visit(var1);
ods graphics on;
proc calis data=sf_z plots=pathdiagram covariance maxiter=50000 method=ml;
   where visit=&var1;
   lineqs
      G1 = LV07 * F2 + E7,
      G2 = LV08 * F2 + E8,
      G3 = LV09 * F2 + E9,
      G4 = LV10 * F2 + E10,
      G5 = LV11 * F2 + E11;
   std
      F2 = 1,
      E7-E11 = vare7-vare11;
cov
      E10 E11 = CE10E11;  
   var
      G1 G2 G3 G4 G5;
run;
ods graphics off;
%mend;
%visit(1);
%visit(7);
%visit(8);

* Emperical model: Mental Health;
%macro visit(var1);
ods graphics on;
proc calis data=sf_z plots=pathdiagram covariance maxiter=50000 method=ml;
   where visit=&var1;
   lineqs
      M1 = LV07 * F2 + E7,
      M3 = LV08 * F2 + E8,
      M5 = LV09 * F2 + E9,
      G2 = LV10 * F2 + E10,
      G5 = LV11 * F2 + E11;
   std
      F2 = 1,
      E7-E11 = vare7-vare11;
   cov
      E10 E11 = CE10E11;  /* Correct placement of covariance statement */
   var
      M1 M3 M5 G2 G5;
   pathdiagram diagram = standard;
run;
ods graphics off;
%mend;
%visit(1);
%visit(7);
%visit(8);

* Emperical model: General Health;
%macro visit(var1);
ods graphics on;
proc calis data=sf_z plots=pathdiagram covariance maxiter=50000 method=ml;
   where visit=&var1;
   lineqs
      G1 = LV07 * F2 + E7,
      G3 = LV08 * F2 + E8,
      G4 = LV09 * F2 + E9,
      M2 = LV10 * F2 + E10,
      M4 = LV11 * F2 + E11;
   std
      F2 = 1,
      E7-E11 = vare7-vare11;
   cov
      E10 E11 = CE10E11;   
   var
      G1 G3 G4 M2 M4;
run;
ods graphics off;
%mend;
%visit(1);
%visit(7);
%visit(8);



